Description:
LMC looks for a chain of delegating methods.
A delegating method does not perform any action but calls
the delegate method. LMC produces a warning message if
the length of such a message chain is higher than the value specified
by the Max call chain length property (2, by default).
Incorrect:
class Array {
private Buffer buf;
int size() {
return buf.size();
}
}
class Buffer {
private List list;
int size() {
return list.size();
}
}
class List {
private ArrayList list;
int size() {
return list.size();
}
}
Refactoring: